<template>
  <div class="big">
    <div class="con">
      <h3>登录</h3>
    <div>
      <el-input placeholder="请输入用户名" clearable v-model="user.username"></el-input>
    </div>
    <div>
      <el-input placeholder="请输入密码" clearable show-password v-model="user.password"></el-input>
    </div>
    <div>
      <el-button type="primary" @click="login">登录</el-button>
    </div>
    </div>
    
  </div>
</template>

<script>
import { requserlogin } from '../../request/api';
import {mapActions} from "vuex"
export default {
  data(){
    return{
      user:{
        username:"",
        password:""
      }
    }
  },
  methods:{
    ...mapActions({
      changeInfo:"changeInfo"
    }),
    login(){
      requserlogin(this.user).then(res=>{
        if(res.data.code==200){
           //登录成功
           //存用户信息
           this.changeInfo(res.data.list)
          //跳转页面
          this.$router.push("/")
        }
      })
     
    }
  }

}
</script>

<style lang="less" scoped>
@import "../../less/index.less";
.big{
  width: 100vw;
  height: 100vh;
  background: linear-gradient(90deg,@primary,@info);
  position: relative;
}
.con{
  width: 300px;
  padding: @margin;
  background:@white;
  position: absolute;
  top:50%;
  left:50%;
  transform: translate(-50%,-50%);
}
h3{
  text-align: @center;
  margin-bottom:@margin;
  
}
.con div{
  margin-bottom: @margin;
  text-align: @center;
}


</style>